﻿//////////////////////////////////////////////////////////////////////////
// util module
// author   : zhangpeng
// date     : 2012-3-1
//////////////////////////////////////////////////////////////////////////
var fs = require("fs");
var util = require("util");
/*
// allready has this function.
function objToStr(obj){
	if (obj === null){
		return "null:null";
	}
	var preStrObj = "{";
	var sufStrObj = "}";
	var strObj = preStrObj;
	for(var att in obj) {
		if (typeof obj[att] == 'function') {
			//strObj += att + " : "+ obj[att].getSelfName();
		} else if (typeof obj[att] === "object"){
			//strObj += objToStr(obj[att]);
		} else{
			strObj += att + " : " + obj[att];
		}
		strObj += ",";
	}
	  
	strObj = strObj.substr(0, strObj.length-1);
	strObj += sufStrObj;
	return strObj;
};
*/
function WriteLog(content, fileName) {
	if (fileName == undefined) {
		fileName = "./log.txt";
	};
	var now = new Date();
    fs.writeFile(fileName, now + "\r\n" + util.inspect(content), "utf8", function(err) {
        if (err) {
            throw err;
        }
    })
}
//exports.ObjToStr = objToStr;
exports.WriteLog = WriteLog;
